#!/bin/bash

# whiptail messages
# shellcheck disable=SC2034
w_title_one="Compile Debian Based Linux Kernel"
w_msg_one="Welcome. This script is intended to help simplify compiling a Linux Kernel.\n\n"
w_msg_one+="There is no magic here, all the commands are standard and you are \n"
w_msg_one+="encouraged to have a look at the code. Powerusers will likely find this \n"
w_msg_one+="script less than useful as there is some bloat and compilation can be \n"
w_msg_one+="done efficiently at the command line with a few instructions. The target \n"
w_msg_one+="audience here is those less comfortable within a terminal and explains the \n"
w_msg_one+="use of whiptail. Hopefully it will take some of the fear away from first \n"
w_msg_one+="timers. \n\n"
w_msg_one+="In short the script will update and / or install the necessary components \n"
w_msg_one+="to compile a *.deb file set, compile same, and then prompt for installation.\n"
w_msg_one+="The *deb files can then be managed in standard package mangers.\n\n"

# shellcheck disable=SC2034
w_title_two="Precompiled Package Not Available"
w_msg_two="The kernel for your detected architecture is not currently available.\n"
w_msg_two+="This indicates a problem with Canoncial, the makers of Ubuntu and\n"
w_msg_two+="not on your local system.\n\nIn most cases you should simply try again later.\n\nExiting and cleaning up."

# shellcheck disable=SC2034
w_title_three="Root User Detected"
w_msg_three="\nThese scripts only need elevated privleges in order to install missing dependencies "
w_msg_three+="or when installing the actual payloads. You are encouraged to use an account "
w_msg_three+="other than \`root\` which is a member of the \`sudo\` group.\n\n"
w_msg_three+="You will be prompted for elevated privleges only when necessary."
w_msg_three+="\n\nWhen compiling using a profile, credentials will be cached so that the script "
w_msg_three+="can continue in a fully unattended manner."

# shellcheck disable=SC2034
w_title_four="Outdated Scripts Detected"
w_msg_four="Your local scripts are not current with the repository.\nIt is recommended "
w_msg_four+="that you exit now and update with:\n\n                                 git pull\n\nthen rerun this script... continue anyway?"

# console messages
c_msg_one="Usage: ${0##*/} [OPTION]\n\n"
c_msg_one+="Bash script that will poll https://kernel.ubuntu.com for available precompiled \nkernels and present the user with a menu for selection and installation.\n\n"
c_msg_one+="Optional arguments:\n"
c_msg_one+="\t  -h, --help  \t  Display this help and exit\n"
c_msg_one+="\t  -l, --latest  \t  Autoselect latest kernel release\n"
c_msg_one+="\t  -o, --low  \t  Autoselect low latency kernel\n"
c_msg_one+="\t  -v, --version  \t  Show version information and exit\n"
c_msg_one+="\nNOTE: Do not mix parameter types:\n"
c_msg_one+="\t  ${Red}WRONG${Reg} \t ./update_ubuntu_kernel ${Red}-l --low${Reg}\n"
c_msg_one+="\t  ${Yellow}RIGHT${Reg} \t ./update_ubuntu_kernel ${Yellow}-lo${Reg}\n"
c_msg_one+="\t  ${Yellow}RIGHT${Reg} \t ./update_ubuntu_kernel ${Yellow}-l -o${Reg}\n"
c_msg_one+="\t  ${Yellow}RIGHT${Reg} \t ./update_ubuntu_kernel ${Yellow}--latest --low${Reg}\n"


c_msg_two="Usage: ${0##*/} [OPTION][=FILE]\n\n"
c_msg_two+="Bash script that will poll https://www.kernel.org for available kernels \nand present the user with a menu for selection, compilation and installation.\n\n"
c_msg_two+="Optional arguments:\n"
c_msg_two+="\t  -A, --archive=FILE  \t  Use a local kernel archive file\n"
c_msg_two+="\t  -h, --help  \t  \t  Display this help and exit\n"
c_msg_two+="\t  -l, --latest  \t    \t  Autoselect latest kernel release\n"
c_msg_two+="\t  -P, --profile=PROFILE   \t  Automatic compilation using a PROFILE file\n"
c_msg_two+="\t  -v, --version  \t   \t  Show version information and exit\n"